home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / misc / letterspace.tex < prev    next >
Text File  |  1993-01-11  |  1KB  |  58 lines

  1. %%% Examples
  2. %
  3. % Letterspacing.tex by Phil Taylor
  4. %
  5. %%% \letterspace {Now is the time for all good men}
  6. %%% \letterspace to \hsize {Now is the time for all good men}
  7. %%% \letterspace spread 0.3 \hsize {Now is the time for all good men}
  8. %%% \letterspace to 1.5 \naturalwidth {Now is the time for all good men}
  9. %%% \letterspace spread 0.5 \naturalwidth {Now is the time for all good men}
  10.  
  11. \newdimen \naturalwidth
  12. \newdimen \naturaldepth
  13. \newdimen \naturalheight
  14.  
  15. \chardef \atcode = \the \catcode `\@
  16. \catcode `\@ = 11
  17.  
  18. \newbox \l@tterspacebox
  19. \newtoks \l@tterspacetoks
  20.  
  21. \let \@x = \expandafter
  22.  
  23. \def \letterspace #1#%
  24.     {\def \hb@xmodifier {#1}%
  25.      \afterassignment \l@tterspace
  26.      \l@tterspacetoks =
  27.     }
  28.  
  29. \def \l@tterspace 
  30.     {\setbox \l@tterspacebox = \hbox {\the \l@tterspacetoks}%
  31.      \naturalwidth =  \wd \l@tterspacebox
  32.      \naturaldepth =  \dp \l@tterspacebox
  33.      \naturalheight = \ht \l@tterspacebox
  34.      \hbox \hb@xmodifier 
  35.         {\@x \l@tt@rspace \@x {\@x }\the \l@tterspacetoks \@nd}%
  36.     }
  37.  
  38. \def \l@tt@rspace #1#2\@nd
  39.     {\def \1{#1}%
  40.      \def \2{#2}%
  41.      \1%
  42.      \ifx \1\empty \else \hss \fi
  43.      \ifx \2\empty
  44.           \let \n@xt = \relax
  45.      \else
  46.           \futurelet \2\m@kespaceexplicit #2\@nd
  47.           \ifx \1\space \hss \hss \fi
  48.           \def \n@xt {\expandafter \l@tt@rspace \2\@nd}%
  49.      \fi
  50.      \n@xt
  51.     }
  52.  
  53. \def \m@kespaceexplicit #1#2\@nd {\if \2 \def \2{{ }#1#2}\else \def \2{#1#2}\fi}
  54.  
  55. \catcode `\@ = \the \atcode
  56.  
  57. \endinput
  58.